import { useDetail, useList } from "@/hooks";
import { getUserInfoUrl } from "@/command/apiTool";
import { useRoute } from "vue-router";
import { watch } from "vue";
import router from "@/router";
export const useRequest = () => {
  // 预约大户详情
  const position = localStorage.getItem("positionData") as string;
  const positionJSON = JSON.parse(position) as {
    latitude: string;
    longitude: string;
  };
  const route = useRoute();
  watch(route, (e) => {
    router.go(0);
  });
  const [queryDhDetail, queryDhDetailControl] = useDetail(
    getUserInfoUrl(
      {
        dh: "",
        xh: "/api/H5/gov/richTraceSourceApply/small/queryDhDetail",
      },
      {
        dhId: route.query.id,
        lat: positionJSON.latitude,
        lng: positionJSON.longitude,
      }
    ),
    {
      entityName: "",
      entityLogo: "",
      majorName: "",
      address: "",
      introduce: "",
      phone: "",
      jl: "",
      productName: "",
      businessDate: "",
      list: [],
    }
  );

  // 大户溯源情况
  const [queryApplyNum] = useDetail(
    getUserInfoUrl(
      {
        dh: "",
        xh: "/api/H5/gov/richTraceSourceApply/small/queryApplyNum",
      },
      {
        id: "4",
      }
    ),
    {}
  );

  const [queryFjDh] = useDetail(
    getUserInfoUrl({
      dh: "",
      xh: "/api/H5/gov/richTraceSourceApply/small/queryFjDh",
    }),
    []
  );

  return {
    queryDhDetail,
    queryApplyNum,
    queryFjDh,
  };
};
